From 74bd5526c005655a45ef39db4c5be76b4bde1604 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Mon, 29 Aug 2005 11:31:47 +0000 Subject: [PATCH] test for type symmetry --- ChangeLog | 5 +++ tests/types.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 tests/types.c diff --git a/ChangeLog b/ChangeLog index bc59154..c9250cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-08-29 Øyvind Kolås + + * tests/types.c: added test that tests the symmetry of reference + conversions for registered types. + 2005-08-29 Øyvind Kolås * babl/babl-format.c: (each_babl_format_destroy), (format_new), diff --git a/tests/types.c b/tests/types.c new file mode 100644 index 0000000..acda129 --- /dev/null +++ b/tests/types.c @@ -0,0 +1,84 @@ +#include "babl.h" +#include "math.h" +#include "babl-internal.h" + +int OK=1; + +double test[] = { + 0.0, 0.5, 1.0, 0.1, 0.9, 1.1, -0.1, -2, 2.0, 100, -100, 200, 200 +}; + +int samples = sizeof(test) / sizeof(test[0]); + +static Babl *double_vector_format (void) +{ + static Babl *self = NULL; + + if (!self) + self = babl_format_new ( + babl_model ("Y"), + babl_type ("double"), + babl_component ("Y"), + NULL); + return self; +} + +int type_check (Babl *babl, + void *userdata) +{ + void *original; + double *clipped; + void *destination; + double *transformed; + + Babl *fmt; + + + original = babl_calloc (1,babl->type.bits/8 * samples); + clipped = babl_calloc (1,64/8 * samples); + destination = babl_calloc (1,babl->type.bits/8 * samples); + transformed = babl_calloc (1,64/8 * samples); + + fmt = babl_format_new (babl_model ("Y"), + babl, + babl_component ("Y"), + NULL); + + babl_process (babl_fish (double_vector_format (), fmt), + test, original, samples); + babl_process (babl_fish (fmt, double_vector_format ()), + original, clipped, samples); + babl_process (babl_fish (double_vector_format (), fmt), + clipped, destination, samples); + babl_process (babl_fish (fmt, double_vector_format ()), + destination, transformed, samples); + { + int i; + for (i=0;i0.00001) + babl_log ("%s: %f %f %f)", + babl->instance.name, test[i], clipped[i], transformed[i] + ); + OK=0; + } + } + + babl_free (original); + babl_free (clipped); + babl_free (destination); + babl_free (transformed); + return 0; +} + +int main (void) +{ + babl_init (); + + babl_set_extender (babl_extension_quiet_log ()); + babl_type_each (type_check, NULL); + + babl_destroy (); + + return !OK; +} -- 2.30.2